// Ollama API 类型定义
export interface OllamaRequest {
  model: string
  prompt: string
  stream?: boolean
  options?: {
    num_predict?: number
    seed?: number
    stop?: string[]
    temperature?: number
    top_k?: number
    top_p?: number
  }
}

export interface OllamaResponse {
  model: string
  created_at: string
  response: string
  done: boolean
  context?: number[]
  total_duration?: number
  load_duration?: number
  prompt_eval_duration?: number
  eval_duration?: number
  eval_count?: number
  eval_token_count?: number
}

// 数据库查询类型定义
export interface DatabaseQuery {
  query: string
  params?: any[]
  options?: {
    maxRows?: number
    timeout?: number
  }
}

export interface QueryResult<T = any> {
  rows: T[]
  rowCount: number
  fields: {
    dataTypeID: number
    dataTypeModifier: number
    dataTypeSize: number
    format: string
    name: string
  }[]
}

// 拦截器类型定义
export interface Interceptor<T = any, R = any> {
  onRequest?: (config: T) => Promise<T> | T
  onResponse?: (response: R) => Promise<R> | R
  onError?: (error: Error) => Error | Promise<Error>
}

// 统一响应类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: null | T
  timestamp: number
}
